package com.navigation;



import com.kogi.patterns.R;
import com.kogi.patterns.dummy;
import com.kogi.patterns.main;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.DataSetObserver;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.Toast;

public class ImageAdapter extends BaseAdapter {
    private Context mContext;
    private int a=0;
    Context context;
    Intent con ;
    public ImageAdapter(Context c) {
        mContext = c;
    }

    public ImageAdapter(primero c, Context aa) {
    	mContext = c;
    	context=aa;
	}

	public int getCount() {
        return mThumbIds.length;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    public View getView(final int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
            //imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(8, 8, 8, 8);
            imageView.setTag(a);
            
            imageView.setOnClickListener(new View.OnClickListener()
            {

              @Override
              public void onClick(View view) 
              {

                  if(position==0)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Bolivia")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==1)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Brazil")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==2)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Chile")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==3)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Colombia")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==4)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Argentina")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==5)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Guyana")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==6)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Ecuador")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==7)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Suriname")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==8)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Paraguay")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==9)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Peru")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==10)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Uruguay")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                  if(position==11)
                  {
                	  AlertDialog.Builder builder = new AlertDialog.Builder(context);
                	  builder.setMessage("Venezuela")
                	         .setCancelable(false)
                	         
                	         .setNegativeButton("ok", new DialogInterface.OnClickListener() {
                	             public void onClick(DialogInterface dialog, int id) {
                	                  dialog.cancel();
                	             }
                	         });
                	  AlertDialog alert = builder.create();
                	  alert.show();
                   }
                    else
                   {
                                //do this
                    }
                           }
                    });



            a++;
        } else {
            imageView = (ImageView) convertView;
        }

        imageView.setImageResource(mThumbIds[position]);
        return imageView;
    }

    // references to our images
    private Integer[] mThumbIds = {
            R.drawable.bl_lgflag, R.drawable.br_lgflag,
            R.drawable.ci_lgflag, R.drawable.co_lgflag,
            R.drawable.ar_lgflag, R.drawable.gy_lgflag,
            R.drawable.ec_lgflag, R.drawable.ns_lgflag,
            R.drawable.pa_lgflag, R.drawable.pe_lgflag,
            R.drawable.uy_lgflag, R.drawable.ve_lgflag
    };

	
}
